package booroo.basic;

public class Pract_P236_Ex2 {

	public static void main(String[] args) {
		Rectangle r = new Rectangle();
		Rectangle s = new Rectangle();
		
		r.setX1(-2);
		r.setY1(2);
		r.setX2(-1);
		r.setY2(4);
		System.out.println(r.toString());
		s.setX1(1);
		s.setY1(1);
		s.setX2(2);
		s.setY2(3);
		System.out.println(s.toString());
		if(r.equals(s))
			System.out.println("두 사각형은 같습니다.");
	}

}

class Rectangle{
	private int x1, y1, x2, y2;
	
	public void setX1(int x1){
		this.x1 = x1;
	}
	public int getX1(){
		return x1;
	}
	public void setY1(int y1){
		this.y1 = y1;
	}
	public int getY1(){
		return y1;
	}
	public void setX2(int x2){
		this.x2 = x2;
	}
	public int getX2(){
		return x2;
	}
	public void setY2(int y2){
		this.y2 = y2;
	}
	public int getY2(){
		return y2;
	}
	public int square(){
		return Math.abs((x1-x2)*(y1-y2));
	}
	@Override
	public String toString() {
		String result = "";
		result = result + "첫번째좌표 " + x1 + "," + y1;
		result += "두번째좌표 " + x2 + "," + y2;
		result += "사각형의 넓이 " + square();
		return result;
	}
	boolean equals(Rectangle r){
		if(square() == r.square()){
			return true;
		}
		else return false;
		 }
}